<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="referrer" content="no-referrer-when-downgrade">
    

    <title>Python3字符串 | 早起的年轻人</title>
    <meta property="og:title" content="Python3字符串 - 早起的年轻人">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-09-15T12:49:58&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-09-15T12:49:58&#43;08:00'>
        
    <meta name="Keywords" content="Flutter，golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序">
    <meta name="description" content="Python3字符串">
        
    <meta name="author" content="luckly">
    <meta property="og:url" content="https://luckly.work/post/python_basic/python3%E5%AD%97%E7%AC%A6%E4%B8%B2/">
    <link rel="shortcut icon" href='/favicon.ico'  type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
        <link href="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>

<link rel="stylesheet"
      href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://luckly.work/">
                        早起的年轻人
                    </a>
                
                <p class="description">专注于Flutter、Android、Java、Go语言(golang)、移动互联网、项目管理、软件架构</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://luckly.work/">首页</a>
                    
                    <a  href="https://luckly.work/categories/" title="分类">分类</a>
                    
                    <a  href="https://luckly.work/tags/" title="标签">标签</a>
                    
                    <a  href="https://luckly.work/archives/" title="归档">归档</a>
                    
                    <a  href="https://luckly.work/about/" title="关于我">关于我</a>
                    
                    <a  href="https://github.com/ITmxs/" title="github">github</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#python-访问字符串中的值">Python 访问字符串中的值</a></li>
    <li><a href="#实例python-30">实例(Python 3.0+)</a></li>
    <li><a href="#python-字符串更新">Python 字符串更新</a></li>
    <li><a href="#实例python-30-1">实例(Python 3.0+)</a></li>
    <li><a href="#python转义字符">Python转义字符</a></li>
    <li><a href="#python字符串运算符">Python字符串运算符</a></li>
    <li><a href="#实例python-30-2">实例(Python 3.0+)</a></li>
    <li><a href="#python-字符串格式化">Python 字符串格式化</a></li>
    <li><a href="#实例python-30-3">实例(Python 3.0+)</a></li>
    <li><a href="#python三引号">Python三引号</a></li>
    <li><a href="#实例python-30-4">实例(Python 3.0+)</a></li>
    <li><a href="#f-string">f-string</a></li>
    <li><a href="#实例">实例</a></li>
    <li><a href="#实例-1">实例</a></li>
    <li><a href="#实例-2">实例</a></li>
    <li><a href="#unicode-字符串">Unicode 字符串</a></li>
    <li><a href="#python-的字符串内建函数">Python 的字符串内建函数</a></li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">Python3字符串</h1>
        </header>
        <date class="post-meta meta-date">
            2021年9月15日
        </date>
        
        <div class="post-meta">
            <span>|</span>
            
            <span class="meta-category"><a href='/categories/python'>python</a></span>
            
        </div>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h1 id="python3-字符串">Python3 字符串</h1>
<p>字符串是 Python 中最常用的数据类型。我们可以使用引号( <strong>'</strong> 或 <strong>&quot;</strong> )来创建字符串。</p>
<p>创建字符串很简单，只要为变量分配一个值即可。例如：</p>
<p>var1 = &lsquo;Hello World!&rsquo; var2 = &ldquo;luckly&rdquo;</p>
<h2 id="python-访问字符串中的值">Python 访问字符串中的值</h2>
<p>Python 不支持单字符类型，单字符在 Python 中也是作为一个字符串使用。</p>
<p>Python 访问子字符串，可以使用方括号 <strong>[]</strong> 来截取字符串，字符串的截取的语法格式如下：</p>
<pre><code>变量[头下标:尾下标]
</code></pre><p>索引值以 <strong>0</strong> 为开始值，<strong>-1</strong> 为从末尾的开始位置。</p>
<p>
        <a data-fancybox="gallery" href="https://luckly007.oss-cn-beijing.aliyuncs.com/image/123456-20200923-1.svg">
            <img class="mx-auto" alt="img" src="https://luckly007.oss-cn-beijing.aliyuncs.com/image/123456-20200923-1.svg" />
        </a>
    </p>
<p>
        <a data-fancybox="gallery" href="https://luckly007.oss-cn-beijing.aliyuncs.com/image/python-str-runoob.png">
            <img class="mx-auto" alt="img" src="https://luckly007.oss-cn-beijing.aliyuncs.com/image/python-str-runoob.png" />
        </a>
    </p>
<p>如下实例：</p>
<h2 id="实例python-30">实例(Python 3.0+)</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#75715e">#!/usr/bin/python3</span>
 
var1 <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;Hello World!&#39;</span>
var2 <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;luckly&#34;</span>
 
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">&#34;var1[0]: &#34;</span>, var1[<span style="color:#ae81ff">0</span>])
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">&#34;var2[1:5]: &#34;</span>, var2[<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">5</span>])
</code></pre></div><p>以上实例执行结果：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python">var1[<span style="color:#ae81ff">0</span>]:  H
var2[<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">5</span>]:  unoo
</code></pre></div><h2 id="python-字符串更新">Python 字符串更新</h2>
<p>你可以截取字符串的一部分并与其他字段拼接，如下实例：</p>
<h2 id="实例python-30-1">实例(Python 3.0+)</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#75715e">#!/usr/bin/python3</span>
 
var1 <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;Hello World!&#39;</span>
 
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">&#34;已更新字符串 : &#34;</span>, var1[:<span style="color:#ae81ff">6</span>] <span style="color:#f92672">+</span> <span style="color:#e6db74">&#39;luckly!&#39;</span>)
</code></pre></div><p>以上实例执行结果</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#960050;background-color:#1e0010">已更新字符串</span> :  Hello luckly<span style="color:#960050;background-color:#1e0010">!</span>
</code></pre></div><h2 id="python转义字符">Python转义字符</h2>
<p>在需要在字符中使用特殊字符时，python 用反斜杠 *<em>*</em> 转义字符。如下表：</p>
<table>
<thead>
<tr>
<th style="text-align:left">转义字符</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">实例</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">(在行尾时)</td>
<td style="text-align:left">续行符</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;line1 \ ... line2 \ ... line3&quot;) line1 line2 line3 &gt;&gt;&gt; </code></td>
</tr>
<tr>
<td style="text-align:left">\</td>
<td style="text-align:left">反斜杠符号</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\\&quot;) \</code></td>
</tr>
<tr>
<td style="text-align:left">'</td>
<td style="text-align:left">单引号</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print('\'') '</code></td>
</tr>
<tr>
<td style="text-align:left">&quot;</td>
<td style="text-align:left">双引号</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\&quot;&quot;) &quot;</code></td>
</tr>
<tr>
<td style="text-align:left">\a</td>
<td style="text-align:left">响铃</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\a&quot;)</code>执行后电脑有响声。</td>
</tr>
<tr>
<td style="text-align:left">\b</td>
<td style="text-align:left">退格(Backspace)</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;Hello \b World!&quot;) Hello World!</code></td>
</tr>
<tr>
<td style="text-align:left">\000</td>
<td style="text-align:left">空</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\000&quot;) &gt;&gt;&gt; </code></td>
</tr>
<tr>
<td style="text-align:left">\n</td>
<td style="text-align:left">换行</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\n&quot;)  &gt;&gt;&gt;</code></td>
</tr>
<tr>
<td style="text-align:left">\v</td>
<td style="text-align:left">纵向制表符</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;Hello \v World!&quot;) Hello        World! &gt;&gt;&gt;</code></td>
</tr>
<tr>
<td style="text-align:left">\t</td>
<td style="text-align:left">横向制表符</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;Hello \t World!&quot;) Hello    World! &gt;&gt;&gt;</code></td>
</tr>
<tr>
<td style="text-align:left">\r</td>
<td style="text-align:left">回车，将 <strong>\r</strong> 后面的内容移到字符串开头，并逐一替换开头部分的字符，直至将 <strong>\r</strong> 后面的内容完全替换完成。</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;Hello\rWorld!&quot;) World! &gt;&gt;&gt; print('google runoob taobao\r123456') 123456 runoob taobao</code></td>
</tr>
<tr>
<td style="text-align:left">\f</td>
<td style="text-align:left">换页</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;Hello \f World!&quot;) Hello        World! &gt;&gt;&gt; </code></td>
</tr>
<tr>
<td style="text-align:left">\yyy</td>
<td style="text-align:left">八进制数，y 代表 0~7 的字符，例如：\012 代表换行。</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\110\145\154\154\157\40\127\157\162\154\144\41&quot;) Hello World!</code></td>
</tr>
<tr>
<td style="text-align:left">\xyy</td>
<td style="text-align:left">十六进制数，以 \x 开头，y 代表的字符，例如：\x0a 代表换行</td>
<td style="text-align:left"><code>&gt;&gt;&gt; print(&quot;\x48\x65\x6c\x6c\x6f\x20\x57\x6f\x72\x6c\x64\x21&quot;) Hello World!</code></td>
</tr>
<tr>
<td style="text-align:left">\other</td>
<td style="text-align:left">其它的字符以普通格式输出</td>
<td style="text-align:left"></td>
</tr>
</tbody>
</table>
<h2 id="python字符串运算符">Python字符串运算符</h2>
<p>下表实例变量 a 值为字符串 &ldquo;Hello&rdquo;，b 变量值为 &ldquo;Python&rdquo;：</p>
<table>
<thead>
<tr>
<th style="text-align:left">操作符</th>
<th style="text-align:left">描述</th>
<th style="text-align:left">实例</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">+</td>
<td style="text-align:left">字符串连接</td>
<td style="text-align:left">a + b 输出结果： HelloPython</td>
</tr>
<tr>
<td style="text-align:left">*</td>
<td style="text-align:left">重复输出字符串</td>
<td style="text-align:left">a*2 输出结果：HelloHello</td>
</tr>
<tr>
<td style="text-align:left">[]</td>
<td style="text-align:left">通过索引获取字符串中字符</td>
<td style="text-align:left">a[1] 输出结果 <strong>e</strong></td>
</tr>
<tr>
<td style="text-align:left">[ : ]</td>
<td style="text-align:left">截取字符串中的一部分，遵循<strong>左闭右开</strong>原则，str[0:2] 是不包含第 3 个字符的。</td>
<td style="text-align:left">a[1:4] 输出结果 <strong>ell</strong></td>
</tr>
<tr>
<td style="text-align:left">in</td>
<td style="text-align:left">成员运算符 - 如果字符串中包含给定的字符返回 True</td>
<td style="text-align:left"><strong>&lsquo;H&rsquo; in a</strong> 输出结果 True</td>
</tr>
<tr>
<td style="text-align:left">not in</td>
<td style="text-align:left">成员运算符 - 如果字符串中不包含给定的字符返回 True</td>
<td style="text-align:left"><strong>&lsquo;M&rsquo; not in a</strong> 输出结果 True</td>
</tr>
<tr>
<td style="text-align:left">r/R</td>
<td style="text-align:left">原始字符串 - 原始字符串：所有的字符串都是直接按照字面的意思来使用，没有转义特殊或不能打印的字符。 原始字符串除在字符串的第一个引号前加上字母 <strong>r</strong>（可以大小写）以外，与普通字符串有着几乎完全相同的语法。</td>
<td style="text-align:left"><code>print( r'\n' ) print( R'\n' )</code></td>
</tr>
<tr>
<td style="text-align:left">%</td>
<td style="text-align:left">格式字符串</td>
<td style="text-align:left">请看下一节内容。</td>
</tr>
</tbody>
</table>
<h2 id="实例python-30-2">实例(Python 3.0+)</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#75715e">#!/usr/bin/python3</span>
 
a <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;Hello&#34;</span>
b <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;Python&#34;</span>
 
<span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;a + b 输出结果：&#34;</span>, a <span style="color:#f92672">+</span> b)
<span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;a * 2 输出结果：&#34;</span>, a <span style="color:#f92672">*</span> <span style="color:#ae81ff">2</span>)
<span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;a[1] 输出结果：&#34;</span>, a[<span style="color:#ae81ff">1</span>])
<span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;a[1:4] 输出结果：&#34;</span>, a[<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">4</span>])
 
<span style="color:#66d9ef">if</span>( <span style="color:#e6db74">&#34;H&#34;</span> <span style="color:#f92672">in</span> a) :
    <span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;H 在变量 a 中&#34;</span>)
<span style="color:#66d9ef">else</span> :
    <span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;H 不在变量 a 中&#34;</span>)
 
<span style="color:#66d9ef">if</span>( <span style="color:#e6db74">&#34;M&#34;</span> <span style="color:#f92672">not</span> <span style="color:#f92672">in</span> a) :
    <span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;M 不在变量 a 中&#34;</span>)
<span style="color:#66d9ef">else</span> :
    <span style="color:#66d9ef">print</span>(<span style="color:#e6db74">&#34;M 在变量 a 中&#34;</span>)
 
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">r</span><span style="color:#e6db74">&#39;\n&#39;</span>)
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">R</span><span style="color:#e6db74">&#39;\n&#39;</span>)
</code></pre></div><p>以上实例输出结果为：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python">a <span style="color:#f92672">+</span> b <span style="color:#960050;background-color:#1e0010">输出结果：</span> HelloPython
a <span style="color:#f92672">*</span> <span style="color:#ae81ff">2</span> <span style="color:#960050;background-color:#1e0010">输出结果：</span> HelloHello
a[<span style="color:#ae81ff">1</span>] <span style="color:#960050;background-color:#1e0010">输出结果：</span> e
a[<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">4</span>] <span style="color:#960050;background-color:#1e0010">输出结果：</span> ell
H <span style="color:#960050;background-color:#1e0010">在变量</span> a <span style="color:#960050;background-color:#1e0010">中</span>
M <span style="color:#960050;background-color:#1e0010">不在变量</span> a <span style="color:#960050;background-color:#1e0010">中</span>
\n
\n
</code></pre></div><h2 id="python-字符串格式化">Python 字符串格式化</h2>
<p>Python 支持格式化字符串的输出 。尽管这样可能会用到非常复杂的表达式，但最基本的用法是将一个值插入到一个有字符串格式符 %s 的字符串中。</p>
<p>在 Python 中，字符串格式化使用与 C 中 sprintf 函数一样的语法。</p>
<h2 id="实例python-30-3">实例(Python 3.0+)</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#75715e">#!/usr/bin/python3</span>
 
<span style="color:#66d9ef">print</span> (<span style="color:#e6db74">&#34;我叫 </span><span style="color:#e6db74">%s</span><span style="color:#e6db74"> 今年 </span><span style="color:#e6db74">%d</span><span style="color:#e6db74"> 岁!&#34;</span> <span style="color:#f92672">%</span> (<span style="color:#e6db74">&#39;小明&#39;</span>, <span style="color:#ae81ff">10</span>))
</code></pre></div><p>以上实例输出结果：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#960050;background-color:#1e0010">我叫</span> <span style="color:#960050;background-color:#1e0010">小明</span> <span style="color:#960050;background-color:#1e0010">今年</span> <span style="color:#ae81ff">10</span> <span style="color:#960050;background-color:#1e0010">岁!</span>
</code></pre></div><p>python字符串格式化符号:</p>
<table>
<thead>
<tr>
<th style="text-align:center">符  号</th>
<th style="text-align:center">描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">%c</td>
<td style="text-align:center">格式化字符及其ASCII码</td>
</tr>
<tr>
<td style="text-align:center">%s</td>
<td style="text-align:center">格式化字符串</td>
</tr>
<tr>
<td style="text-align:center">%d</td>
<td style="text-align:center">格式化整数</td>
</tr>
<tr>
<td style="text-align:center">%u</td>
<td style="text-align:center">格式化无符号整型</td>
</tr>
<tr>
<td style="text-align:center">%o</td>
<td style="text-align:center">格式化无符号八进制数</td>
</tr>
<tr>
<td style="text-align:center">%x</td>
<td style="text-align:center">格式化无符号十六进制数</td>
</tr>
<tr>
<td style="text-align:center">%X</td>
<td style="text-align:center">格式化无符号十六进制数（大写）</td>
</tr>
<tr>
<td style="text-align:center">%f</td>
<td style="text-align:center">格式化浮点数字，可指定小数点后的精度</td>
</tr>
<tr>
<td style="text-align:center">%e</td>
<td style="text-align:center">用科学计数法格式化浮点数</td>
</tr>
<tr>
<td style="text-align:center">%E</td>
<td style="text-align:center">作用同%e，用科学计数法格式化浮点数</td>
</tr>
<tr>
<td style="text-align:center">%g</td>
<td style="text-align:center">%f和%e的简写</td>
</tr>
<tr>
<td style="text-align:center">%G</td>
<td style="text-align:center">%f 和 %E 的简写</td>
</tr>
<tr>
<td style="text-align:center">%p</td>
<td style="text-align:center">用十六进制数格式化变量的地址</td>
</tr>
</tbody>
</table>
<p>格式化操作符辅助指令:</p>
<table>
<thead>
<tr>
<th style="text-align:left">符号</th>
<th style="text-align:left">功能</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">*</td>
<td style="text-align:left">定义宽度或者小数点精度</td>
</tr>
<tr>
<td style="text-align:left">-</td>
<td style="text-align:left">用做左对齐</td>
</tr>
<tr>
<td style="text-align:left">+</td>
<td style="text-align:left">在正数前面显示加号( + )</td>
</tr>
<tr>
<td style="text-align:left"><!-- raw HTML omitted --></td>
<td style="text-align:left">在正数前面显示空格</td>
</tr>
<tr>
<td style="text-align:left">#</td>
<td style="text-align:left">在八进制数前面显示零(&lsquo;0&rsquo;)，在十六进制前面显示'0x&rsquo;或者'0X'(取决于用的是&rsquo;x&rsquo;还是&rsquo;X')</td>
</tr>
<tr>
<td style="text-align:left">0</td>
<td style="text-align:left">显示的数字前面填充'0&rsquo;而不是默认的空格</td>
</tr>
<tr>
<td style="text-align:left">%</td>
<td style="text-align:left">&lsquo;%%&lsquo;输出一个单一的&rsquo;%&rsquo;</td>
</tr>
<tr>
<td style="text-align:left">(var)</td>
<td style="text-align:left">映射变量(字典参数)</td>
</tr>
<tr>
<td style="text-align:left">m.n.</td>
<td style="text-align:left">m 是显示的最小总宽度,n 是小数点后的位数(如果可用的话)</td>
</tr>
</tbody>
</table>
<p>Python2.6 开始，新增了一种格式化字符串的函数 <a href="https://www.runoob.com/python/att-string-format.html">str.format()</a>，它增强了字符串格式化的功能。</p>
<hr>
<h2 id="python三引号">Python三引号</h2>
<p>python三引号允许一个字符串跨多行，字符串中可以包含换行符、制表符以及其他特殊字符。实例如下</p>
<h2 id="实例python-30-4">实例(Python 3.0+)</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#75715e">#!/usr/bin/python3</span>
 
para_str <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;&#34;&#34;这是一个多行字符串的实例
</span><span style="color:#e6db74">多行字符串可以使用制表符
</span><span style="color:#e6db74">TAB ( </span><span style="color:#ae81ff">\t</span><span style="color:#e6db74"> )。
</span><span style="color:#e6db74">也可以使用换行符 [ </span><span style="color:#ae81ff">\n</span><span style="color:#e6db74"> ]。
</span><span style="color:#e6db74">&#34;&#34;&#34;</span>
<span style="color:#66d9ef">print</span> (para_str)
</code></pre></div><p>以上实例执行结果为：</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#960050;background-color:#1e0010">这是一个多行字符串的实例</span>
<span style="color:#960050;background-color:#1e0010">多行字符串可以使用制表符</span>
TAB (    )<span style="color:#960050;background-color:#1e0010">。</span>
<span style="color:#960050;background-color:#1e0010">也可以使用换行符</span> [ 
 ]<span style="color:#960050;background-color:#1e0010">。</span>
</code></pre></div><p>三引号让程序员从引号和特殊字符串的泥潭里面解脱出来，自始至终保持一小块字符串的格式是所谓的WYSIWYG（所见即所得）格式的。</p>
<p>一个典型的用例是，当你需要一块HTML或者SQL时，这时用字符串组合，特殊字符串转义将会非常的繁琐。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python">errHTML <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;&#39;&#39;
</span><span style="color:#e6db74">&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;
</span><span style="color:#e6db74">Friends CGI Demo&lt;/TITLE&gt;&lt;/HEAD&gt;
</span><span style="color:#e6db74">&lt;BODY&gt;&lt;H3&gt;ERROR&lt;/H3&gt;
</span><span style="color:#e6db74">&lt;B&gt;</span><span style="color:#e6db74">%s</span><span style="color:#e6db74">&lt;/B&gt;&lt;P&gt;
</span><span style="color:#e6db74">&lt;FORM&gt;&lt;INPUT TYPE=button VALUE=Back
</span><span style="color:#e6db74">ONCLICK=&#34;window.history.back()&#34;&gt;&lt;/FORM&gt;
</span><span style="color:#e6db74">&lt;/BODY&gt;&lt;/HTML&gt;
</span><span style="color:#e6db74">&#39;&#39;&#39;</span>
cursor<span style="color:#f92672">.</span>execute(<span style="color:#e6db74">&#39;&#39;&#39;
</span><span style="color:#e6db74">CREATE TABLE users (  
</span><span style="color:#e6db74">login VARCHAR(8), 
</span><span style="color:#e6db74">uid INTEGER,
</span><span style="color:#e6db74">prid INTEGER)
</span><span style="color:#e6db74">&#39;&#39;&#39;</span>)
</code></pre></div><hr>
<h2 id="f-string">f-string</h2>
<p>f-string 是 python3.6 之后版本添加的，称之为字面量格式化字符串，是新的格式化字符串的语法。</p>
<p>之前我们习惯用百分号 (%):</p>
<h2 id="实例">实例</h2>
<pre><code>&gt;&gt;&gt; name = 'luckly'
&gt;&gt;&gt; 'Hello %s' % name
'Hello luckly'
</code></pre><p><strong>f-string</strong> 格式化字符串以 <strong>f</strong> 开头，后面跟着字符串，字符串中的表达式用大括号 {} 包起来，它会将变量或表达式计算后的值替换进去，实例如下：</p>
<h2 id="实例-1">实例</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#f92672">&gt;&gt;&gt;</span> name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;luckly&#39;</span>
<span style="color:#f92672">&gt;&gt;&gt;</span> f<span style="color:#e6db74">&#39;Hello {name}&#39;</span>  <span style="color:#75715e"># 替换变量</span>
<span style="color:#e6db74">&#39;Hello luckly&#39;</span>
<span style="color:#f92672">&gt;&gt;&gt;</span> f<span style="color:#e6db74">&#39;{1+2}&#39;</span>         <span style="color:#75715e"># 使用表达式</span>
<span style="color:#e6db74">&#39;3&#39;</span>

<span style="color:#f92672">&gt;&gt;&gt;</span> w <span style="color:#f92672">=</span> {<span style="color:#e6db74">&#39;name&#39;</span>: <span style="color:#e6db74">&#39;luckly&#39;</span>, <span style="color:#e6db74">&#39;url&#39;</span>: <span style="color:#e6db74">&#39;www.runoob.com&#39;</span>}
<span style="color:#f92672">&gt;&gt;&gt;</span> f<span style="color:#e6db74">&#39;{w[&#34;name&#34;]}: {w[&#34;url&#34;]}&#39;</span>
<span style="color:#e6db74">&#39;luckly: www.runoob.com&#39;</span>
</code></pre></div><p>用了这种方式明显更简单了，不用再去判断使用 %s，还是 %d。</p>
<p>在 Python 3.8 的版本中可以使用 <strong>=</strong> 符号来拼接运算表达式与结果：</p>
<h2 id="实例-2">实例</h2>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-python" data-lang="python"><span style="color:#f92672">&gt;&gt;&gt;</span> x <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>
<span style="color:#f92672">&gt;&gt;&gt;</span> <span style="color:#66d9ef">print</span>(f<span style="color:#e6db74">&#39;{x+1}&#39;</span>)   <span style="color:#75715e"># Python 3.6</span>
<span style="color:#ae81ff">2</span>

<span style="color:#f92672">&gt;&gt;&gt;</span> x <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>
<span style="color:#f92672">&gt;&gt;&gt;</span> <span style="color:#66d9ef">print</span>(f<span style="color:#e6db74">&#39;{x+1=}&#39;</span>)   <span style="color:#75715e"># Python 3.8</span>
x<span style="color:#f92672">+</span><span style="color:#ae81ff">1</span><span style="color:#f92672">=</span><span style="color:#ae81ff">2</span>
</code></pre></div><hr>
<h2 id="unicode-字符串">Unicode 字符串</h2>
<p>在Python2中，普通字符串是以8位ASCII码进行存储的，而Unicode字符串则存储为16位unicode字符串，这样能够表示更多的字符集。使用的语法是在字符串前面加上前缀 <strong>u</strong>。</p>
<p>在Python3中，所有的字符串都是Unicode字符串。</p>
<hr>
<h2 id="python-的字符串内建函数">Python 的字符串内建函数</h2>
<p>Python 的字符串常用内建函数如下：</p>
<table>
<thead>
<tr>
<th style="text-align:left">序号</th>
<th style="text-align:center">方法及描述</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">1</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-capitalize.html">capitalize()</a> 将字符串的第一个字符转换为大写</td>
</tr>
<tr>
<td style="text-align:left">2</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-center.html">center(width, fillchar)</a> 返回一个指定的宽度 width 居中的字符串，fillchar 为填充的字符，默认为空格。</td>
</tr>
<tr>
<td style="text-align:left">3</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-count.html">count(str, beg= 0,end=len(string))</a> 返回 str 在 string 里面出现的次数，如果 beg 或者 end 指定则返回指定范围内 str 出现的次数</td>
</tr>
<tr>
<td style="text-align:left">4</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-decode.html">bytes.decode(encoding=&ldquo;utf-8&rdquo;, errors=&ldquo;strict&rdquo;)</a> Python3 中没有 decode 方法，但我们可以使用 bytes 对象的 decode() 方法来解码给定的 bytes 对象，这个 bytes 对象可以由 str.encode() 来编码返回。</td>
</tr>
<tr>
<td style="text-align:left">5</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-encode.html">encode(encoding=&lsquo;UTF-8&rsquo;,errors=&lsquo;strict&rsquo;)</a> 以 encoding 指定的编码格式编码字符串，如果出错默认报一个ValueError 的异常，除非 errors 指定的是&rsquo;ignore&rsquo;或者&rsquo;replace'</td>
</tr>
<tr>
<td style="text-align:left">6</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-endswith.html">endswith(suffix, beg=0, end=len(string))</a> 检查字符串是否以 obj 结束，如果beg 或者 end 指定则检查指定的范围内是否以 obj 结束，如果是，返回 True,否则返回 False.</td>
</tr>
<tr>
<td style="text-align:left">7</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-expandtabs.html">expandtabs(tabsize=8)</a> 把字符串 string 中的 tab 符号转为空格，tab 符号默认的空格数是 8 。</td>
</tr>
<tr>
<td style="text-align:left">8</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-find.html">find(str, beg=0, end=len(string))</a> 检测 str 是否包含在字符串中，如果指定范围 beg 和 end ，则检查是否包含在指定范围内，如果包含返回开始的索引值，否则返回-1</td>
</tr>
<tr>
<td style="text-align:left">9</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-index.html">index(str, beg=0, end=len(string))</a> 跟find()方法一样，只不过如果str不在字符串中会报一个异常。</td>
</tr>
<tr>
<td style="text-align:left">10</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isalnum.html">isalnum()</a> 如果字符串至少有一个字符并且所有字符都是字母或数字则返 回 True，否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">11</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isalpha.html">isalpha()</a> 如果字符串至少有一个字符并且所有字符都是字母或中文字则返回 True, 否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">12</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isdigit.html">isdigit()</a> 如果字符串只包含数字则返回 True 否则返回 False..</td>
</tr>
<tr>
<td style="text-align:left">13</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-islower.html">islower()</a> 如果字符串中包含至少一个区分大小写的字符，并且所有这些(区分大小写的)字符都是小写，则返回 True，否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">14</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isnumeric.html">isnumeric()</a> 如果字符串中只包含数字字符，则返回 True，否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">15</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isspace.html">isspace()</a> 如果字符串中只包含空白，则返回 True，否则返回 False.</td>
</tr>
<tr>
<td style="text-align:left">16</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-istitle.html">istitle()</a> 如果字符串是标题化的(见 title())则返回 True，否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">17</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isupper.html">isupper()</a> 如果字符串中包含至少一个区分大小写的字符，并且所有这些(区分大小写的)字符都是大写，则返回 True，否则返回 False</td>
</tr>
<tr>
<td style="text-align:left">18</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-join.html">join(seq)</a> 以指定字符串作为分隔符，将 seq 中所有的元素(的字符串表示)合并为一个新的字符串</td>
</tr>
<tr>
<td style="text-align:left">19</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-len.html">len(string)</a> 返回字符串长度</td>
</tr>
<tr>
<td style="text-align:left">20</td>
<td style="text-align:center">[ljust(width<a href="https://www.runoob.com/python3/python3-string-ljust.html">, fillchar])</a> 返回一个原字符串左对齐,并使用 fillchar 填充至长度 width 的新字符串，fillchar 默认为空格。</td>
</tr>
<tr>
<td style="text-align:left">21</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-lower.html">lower()</a> 转换字符串中所有大写字符为小写.</td>
</tr>
<tr>
<td style="text-align:left">22</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-lstrip.html">lstrip()</a> 截掉字符串左边的空格或指定字符。</td>
</tr>
<tr>
<td style="text-align:left">23</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-maketrans.html">maketrans()</a> 创建字符映射的转换表，对于接受两个参数的最简单的调用方式，第一个参数是字符串，表示需要转换的字符，第二个参数也是字符串表示转换的目标。</td>
</tr>
<tr>
<td style="text-align:left">24</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-max.html">max(str)</a> 返回字符串 str 中最大的字母。</td>
</tr>
<tr>
<td style="text-align:left">25</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-min.html">min(str)</a> 返回字符串 str 中最小的字母。</td>
</tr>
<tr>
<td style="text-align:left">26</td>
<td style="text-align:center">[replace(old, new <a href="https://www.runoob.com/python3/python3-string-replace.html">, max])</a> 把 将字符串中的 old 替换成 new,如果 max 指定，则替换不超过 max 次。</td>
</tr>
<tr>
<td style="text-align:left">27</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-rfind.html">rfind(str, beg=0,end=len(string))</a> 类似于 find()函数，不过是从右边开始查找.</td>
</tr>
<tr>
<td style="text-align:left">28</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-rindex.html">rindex( str, beg=0, end=len(string))</a> 类似于 index()，不过是从右边开始.</td>
</tr>
<tr>
<td style="text-align:left">29</td>
<td style="text-align:center">[rjust(width,<a href="https://www.runoob.com/python3/python3-string-rjust.html">, fillchar])</a> 返回一个原字符串右对齐,并使用fillchar(默认空格）填充至长度 width 的新字符串</td>
</tr>
<tr>
<td style="text-align:left">30</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-rstrip.html">rstrip()</a> 删除字符串末尾的空格或指定字符。</td>
</tr>
<tr>
<td style="text-align:left">31</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-split.html">split(str=&quot;&quot;, num=string.count(str))</a> 以 str 为分隔符截取字符串，如果 num 有指定值，则仅截取 num+1 个子字符串</td>
</tr>
<tr>
<td style="text-align:left">32</td>
<td style="text-align:center">[splitlines(<a href="https://www.runoob.com/python3/python3-string-splitlines.html">keepends])</a> 按照行('\r', &lsquo;\r\n&rsquo;, \n')分隔，返回一个包含各行作为元素的列表，如果参数 keepends 为 False，不包含换行符，如果为 True，则保留换行符。</td>
</tr>
<tr>
<td style="text-align:left">33</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-startswith.html">startswith(substr, beg=0,end=len(string))</a> 检查字符串是否是以指定子字符串 substr 开头，是则返回 True，否则返回 False。如果beg 和 end 指定值，则在指定范围内检查。</td>
</tr>
<tr>
<td style="text-align:left">34</td>
<td style="text-align:center">[strip(<a href="https://www.runoob.com/python3/python3-string-strip.html">chars])</a> 在字符串上执行 lstrip()和 rstrip()</td>
</tr>
<tr>
<td style="text-align:left">35</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-swapcase.html">swapcase()</a> 将字符串中大写转换为小写，小写转换为大写</td>
</tr>
<tr>
<td style="text-align:left">36</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-title.html">title()</a> 返回&quot;标题化&quot;的字符串,就是说所有单词都是以大写开始，其余字母均为小写(见 istitle())</td>
</tr>
<tr>
<td style="text-align:left">37</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-translate.html">translate(table, deletechars=&quot;&quot;)</a> 根据 str 给出的表(包含 256 个字符)转换 string 的字符, 要过滤掉的字符放到 deletechars 参数中</td>
</tr>
<tr>
<td style="text-align:left">38</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-upper.html">upper()</a> 转换字符串中的小写字母为大写</td>
</tr>
<tr>
<td style="text-align:left">39</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-zfill.html">zfill (width)</a> 返回长度为 width 的字符串，原字符串右对齐，前面填充0</td>
</tr>
<tr>
<td style="text-align:left">40</td>
<td style="text-align:center"><a href="https://www.runoob.com/python3/python3-string-isdecimal.html">isdecimal()</a> 检查字符串是否只包含十进制字符，如果是返回 true，否则返回 false。</td>
</tr>
</tbody>
</table>

        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://luckly.work/">luckly</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://luckly.work/post/python_basic/python3%E5%AD%97%E7%AC%A6%E4%B8%B2/">https://luckly.work/post/python_basic/python3%E5%AD%97%E7%AC%A6%E4%B8%B2/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/post/python_basic/python3%E6%95%B0%E5%AD%97/">Python3数字</a></li>
        
        <li><a href="/post/python_basic/python3%E8%BF%90%E7%AE%97%E7%AC%A6/">Python3运算符</a></li>
        
        <li><a href="/post/python_basic/python3%E6%B3%A8%E9%87%8A/">Python3注释</a></li>
        
        <li><a href="/post/python_basic/python3%E8%A7%A3%E9%87%8A%E5%99%A8/">Python3解释器</a></li>
        
        <li><a href="/post/python_basic/python3%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B/">Python3基本数据类型</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='/tags/python'>python</a></li>
                
            </ul>
            
        </div>
    </article>
    
    

    
    
    <div class="post bg-white">
      <script src="https://utteranc.es/client.js"
            repo= "https://github.com/ITmxs/repo"
            issue-term="pathname"
            theme="github-light"
            crossorigin="anonymous"
            async>
      </script>
    </div>
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2021 <a href="https://luckly.work/">早起的年轻人 By luckly</a>
        
        | <a rel="nofollow" target="_blank" href="http://beian.miit.gov.cn/">粤ICP备2021号-1</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://juejin.cn/user/3843548384077192" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">掘金</span></a>
        </div>
        <div class="github-badge">
            <a href="https://space.bilibili.com/480883651" target="_black"><span class="badge-subject">Design by</span><span class="badge-value bg-brightgreen">早起的年轻人</span></a>
        </div>
        <div class="github-badge">
            <a href="https://cloud.tencent.com/developer/user/6702670" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">云社区</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script><script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>
    <script src="/js/copy-to-clipboard.js"></script>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://luckly.work/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://luckly.work/">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://luckly.work/post/nginx/nginx%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9/" title="Nginx文件内容">Nginx文件内容</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/nginx/nginx%E6%9E%81%E7%AE%80%E6%95%99%E7%A8%8B/" title="Nginx极简教程">Nginx极简教程</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/nginx/%E5%8D%81%E5%88%86%E9%92%9F%E5%85%A5%E9%97%A8nginx/" title="十分钟入门Nginx">十分钟入门Nginx</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/go/Goland%E8%BF%9C%E7%A8%8B%E5%BC%80%E5%8F%91%E9%85%8D%E7%BD%AE/" title="Goland远程开发配置">Goland远程开发配置</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/%E8%AF%BB%E4%B9%A6/%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90/" title="域名解析">域名解析</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/git/%E6%8F%90%E4%BA%A4%E8%BF%87%E7%A8%8B%E7%9C%81%E7%95%A5%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6/" title="提交过程省略某些文件">提交过程省略某些文件</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter_DropdownButton%E7%A4%BA%E4%BE%8B/" title="Flutter_DropdownButton示例">Flutter_DropdownButton示例</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter_ExpansionPanelList%E5%92%8CExpansionPanelList.radio%E7%A4%BA%E4%BE%8B/" title="Flutter_ExpansionPanelList和ExpansionPanelList">Flutter_ExpansionPanelList和ExpansionPanelList</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter%E5%BE%AE%E4%BF%A1%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E8%B7%B3%E5%9B%9EApp%E6%8C%87%E5%AE%9A%E9%A1%B5%E9%9D%A2/" title="Flutter微信分享链接跳回App指定页面">Flutter微信分享链接跳回App指定页面</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F/%E5%A4%96%E5%8C%85%E5%8F%AF%E8%83%BD%E7%9A%84%E9%97%AE%E9%A2%98/" title="外包可能的问题">外包可能的问题</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href='/categories/'>分类</a></h3>
<ul class="widget-list">
    
    <li><a href="https://luckly.work/categories/Flutter/">Flutter (326)</a></li>
    
    <li><a href="https://luckly.work/categories/IT/">IT (2)</a></li>
    
    <li><a href="https://luckly.work/categories/Kotlin/">Kotlin (2)</a></li>
    
    <li><a href="https://luckly.work/categories/Mysql/">Mysql (1)</a></li>
    
    <li><a href="https://luckly.work/categories/nginx/">nginx (1)</a></li>
    
    <li><a href="https://luckly.work/categories/Vue/">Vue (6)</a></li>
    
    <li><a href="https://luckly.work/categories/YouTube%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD/">YouTube视频下载 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/android/">android (6)</a></li>
    
    <li><a href="https://luckly.work/categories/dart/">dart (96)</a></li>
    
    <li><a href="https://luckly.work/categories/Flutter/">Flutter (28)</a></li>
    
    <li><a href="https://luckly.work/categories/gin/">gin (25)</a></li>
    
    <li><a href="https://luckly.work/categories/git/">git (4)</a></li>
    
    <li><a href="https://luckly.work/categories/Go/">Go (102)</a></li>
    
    <li><a href="https://luckly.work/categories/gorm/">gorm (4)</a></li>
    
    <li><a href="https://luckly.work/categories/grpc/">grpc (1)</a></li>
    
    <li><a href="https://luckly.work/categories/html/">html (3)</a></li>
    
    <li><a href="https://luckly.work/categories/ios/">ios (1)</a></li>
    
    <li><a href="https://luckly.work/categories/linux/">linux (1)</a></li>
    
    <li><a href="https://luckly.work/categories/nginx/">nginx (6)</a></li>
    
    <li><a href="https://luckly.work/categories/python/">python (35)</a></li>
    
    <li><a href="https://luckly.work/categories/read/">读书笔记 (6)</a></li>
    
    <li><a href="https://luckly.work/categories/redis/">redis (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B8%AA%E4%BA%BA%E8%B5%84%E6%96%99/">个人资料 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B9%A6%E5%8D%95/">书单 (8)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B9%A6%E8%AF%84/">书评 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统管理师 (19)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统项目管理师 (25)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%8E%9F%E5%88%99/">原则 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%8E%9F%E7%94%9F%E9%80%9A%E8%AE%AF/">原生通讯 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%9F%BA%E7%A1%80/">基础 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%A4%8D%E5%88%A9%E6%95%88%E5%BA%94/">复利效应 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%B0%91%E6%9C%89%E4%BA%BA%E8%B5%B0%E7%9A%84%E8%B7%AF/">少有人走的路 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%BF%83%E8%AF%AD/">心语 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E6%8F%92%E4%BB%B6/">插件 (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E6%95%99%E5%AD%A6/">教学 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%8E%8B%E9%98%B3%E6%98%8E/">王阳明 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%94%B5%E5%AD%90%E4%B9%A6/">电子书 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%99%BB%E9%99%86%E8%A1%A8%E5%8D%95/">登陆表单 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%A8%BB%E7%9B%9B%E5%92%8C%E5%A4%AB/">稻盛和夫 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%A9%B7%E7%88%B8%E7%88%B8%E5%AF%8C%E7%88%B8%E7%88%B8/">穷爸爸富爸爸 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%B2%BE%E8%BF%9B/">精进 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%BC%96%E7%A8%8B/">编程 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%99%9A%E5%B9%BB/">虚幻 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B4%A2%E5%8A%A1%E8%87%AA%E7%94%B1%E4%B9%8B%E8%B7%AF/">财务自由之路 (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%91%E6%AD%A5/">跑步 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%AF%E7%94%B1%E4%BC%A0%E5%8F%82/">路由传参 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%AF%E7%BA%BF/">路线 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%BD%AF%E4%BB%B6%E5%AE%9E%E6%96%BD/">软件实施 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%98%B3%E6%98%8E%E5%BF%83%E5%AD%A6/">阳明心学 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%A1%B9%E7%9B%AE/">项目 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%AD%85%E5%8A%9B/">魅力 (1)</a></li>
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href='/tags/'>标签</a></h3>
<div class="tagcloud">
    
    <a href="https://luckly.work/tags/flutter/">flutter</a>
    
    <a href="https://luckly.work/tags/IT/">IT</a>
    
    <a href="https://luckly.work/tags/Kotlin/">Kotlin</a>
    
    <a href="https://luckly.work/tags/Mysql/">Mysql</a>
    
    <a href="https://luckly.work/tags/nginx/">nginx</a>
    
    <a href="https://luckly.work/tags/Vue/">Vue</a>
    
    <a href="https://luckly.work/tags/YouTube%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD/">YouTube视频下载</a>
    
    <a href="https://luckly.work/tags/android/">android</a>
    
    <a href="https://luckly.work/tags/dart/">dart</a>
    
    <a href="https://luckly.work/tags/flutter/">flutter</a>
    
    <a href="https://luckly.work/tags/gin/">gin</a>
    
    <a href="https://luckly.work/tags/git/">git</a>
    
    <a href="https://luckly.work/tags/go/">go</a>
    
    <a href="https://luckly.work/tags/gorm/">gorm</a>
    
    <a href="https://luckly.work/tags/grpc/">grpc</a>
    
    <a href="https://luckly.work/tags/html/">html</a>
    
    <a href="https://luckly.work/tags/ios/">ios</a>
    
    <a href="https://luckly.work/tags/linux/">linux</a>
    
    <a href="https://luckly.work/tags/nginx/">nginx</a>
    
    <a href="https://luckly.work/tags/python/">python</a>
    
    <a href="https://luckly.work/tags/redis/">redis</a>
    
    <a href="https://luckly.work/tags/%E4%B8%AA%E4%BA%BA%E8%B5%84%E6%96%99/">个人资料</a>
    
    <a href="https://luckly.work/tags/%E4%B9%A6%E5%8D%95/">书单</a>
    
    <a href="https://luckly.work/tags/%E4%B9%A6%E8%AF%84/">书评</a>
    
    <a href="https://luckly.work/tags/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统管理师</a>
    
    <a href="https://luckly.work/tags/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统项目管理师</a>
    
    <a href="https://luckly.work/tags/%E5%85%A5%E9%97%A8/">入门</a>
    
    <a href="https://luckly.work/tags/%E5%8E%9F%E5%88%99/">原则</a>
    
    <a href="https://luckly.work/tags/%E5%8E%9F%E7%94%9F%E9%80%9A%E8%AE%AF/">原生通讯</a>
    
    <a href="https://luckly.work/tags/%E5%9F%BA%E7%A1%80/">基础</a>
    
    <a href="https://luckly.work/tags/%E5%A4%8D%E5%88%A9%E6%95%88%E5%BA%94/">复利效应</a>
    
    <a href="https://luckly.work/tags/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程</a>
    
    <a href="https://luckly.work/tags/%E5%B0%91%E6%9C%89%E4%BA%BA%E8%B5%B0%E7%9A%84%E8%B7%AF/">少有人走的路</a>
    
    <a href="https://luckly.work/tags/%E5%BF%83%E8%AF%AD/">心语</a>
    
    <a href="https://luckly.work/tags/%E6%8F%92%E4%BB%B6/">插件</a>
    
    <a href="https://luckly.work/tags/%E6%95%99%E5%AD%A6/">教学</a>
    
    <a href="https://luckly.work/tags/%E7%8E%8B%E9%98%B3%E6%98%8E/">王阳明</a>
    
    <a href="https://luckly.work/tags/%E7%94%B5%E5%AD%90%E4%B9%A6/">电子书</a>
    
    <a href="https://luckly.work/tags/%E7%99%BB%E9%99%86%E8%A1%A8%E5%8D%95/">登陆表单</a>
    
    <a href="https://luckly.work/tags/%E7%A8%BB%E7%9B%9B%E5%92%8C%E5%A4%AB/">稻盛和夫</a>
    
    <a href="https://luckly.work/tags/%E7%A9%B7%E7%88%B8%E7%88%B8%E5%AF%8C%E7%88%B8%E7%88%B8/">穷爸爸富爸爸</a>
    
    <a href="https://luckly.work/tags/%E7%B2%BE%E8%BF%9B/">精进</a>
    
    <a href="https://luckly.work/tags/%E7%BC%96%E7%A8%8B/">编程</a>
    
    <a href="https://luckly.work/tags/%E8%99%9A%E5%B9%BB/">虚幻</a>
    
    <a href="https://luckly.work/tags/%E8%AF%97/">诗</a>
    
    <a href="https://luckly.work/tags/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/">读书笔记</a>
    
    <a href="https://luckly.work/tags/%E8%B4%A2%E5%8A%A1%E8%87%AA%E7%94%B1%E4%B9%8B%E8%B7%AF/">财务自由之路</a>
    
    <a href="https://luckly.work/tags/%E8%B7%91%E6%AD%A5/">跑步</a>
    
    <a href="https://luckly.work/tags/%E8%B7%AF%E7%94%B1%E4%BC%A0%E5%8F%82/">路由传参</a>
    
    <a href="https://luckly.work/tags/%E8%B7%AF%E7%BA%BF/">路线</a>
    
    <a href="https://luckly.work/tags/%E8%BD%AF%E4%BB%B6%E5%AE%9E%E6%96%BD/">软件实施</a>
    
    <a href="https://luckly.work/tags/%E9%80%9A%E8%AE%AF%E5%BD%95/">通讯录</a>
    
    <a href="https://luckly.work/tags/%E9%98%B3%E6%98%8E%E5%BF%83%E5%AD%A6/">阳明心学</a>
    
    <a href="https://luckly.work/tags/%E9%A1%B9%E7%9B%AE/">项目</a>
    
    <a href="https://luckly.work/tags/%E9%AD%85%E5%8A%9B/">魅力</a>
    
</div>
    </section>

    
<section class="widget">
    <h3 class="widget-title">友情链接</h3>
    <ul class="widget-list">
        
        <li>
            <a target="_blank" href="http://www.topgoer.com/" title="枯藤">枯藤</a>
        </li>
        
        <li>
            <a target="_blank" href="https://gorm.cn/zh_CN/docs/index.html" title="gorm">gorm</a>
        </li>
        
        <li>
            <a target="_blank" href="https://docs.python.org/zh-cn/3/tutorial/index.html" title="python">python</a>
        </li>
        
        <li>
            <a target="_blank" href="https://www.liwenzhou.com/" title="李文周">李文周的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="http://www.xbzweb.com/" title="小包子的博客">小包子的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://www.flysnow.org/" title="飞雪无情的博客">飞雪无情的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://sliverhorn.com/" title="sliverhorn的博客">sliverhorn的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="http://yuedu.baidu.com/ebook/14a722970740be1e640e9a3e" title="Android Gradle权威指南">Android Gradle权威指南</a>
        </li>
        
        <li>
            <a target="_blank" href="https://gesdh.cn/" title="小格子">格子导航</a>
        </li>
        
        <li>
            <a target="_blank" href="https://itachi.xyz/" title="阿林">itachi&#39;s Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="https://darjun.github.io/" title="大俊">大俊Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="https://geektutu.com/post/quick-golang.html" title="极客兔兔">极客兔兔Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="http://zxfcumtcs.github.io/" title="赵雪峰">雪峰Blog</a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://luckly.work/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>